<?php
/**
 * Created by PhpStorm.
 * User: ZhuXueSong
 * Date: 2019-07-01
 * Time: 09:46
 */

namespace App\Services\Third;

use App\Exceptions\ExceptionSms;
use App\Http\Request;
use App\Models\ThirdUse;
use App\Models\UserSms;

/**
 * 实名认证-掌榕网
 * Class SmsZRW
 * @package App\Services\Third
 */
class CertifyZRW extends Base
{
    private $accessKey;
    private $secret;
    private $srvUrl = 'http://cms.1cloudsp.com';

    /**
     * Sms constructor.
     * @param $accessKey
     * @param $secret
     */
    public function __construct($accessKey, $secret)
    {
        $this->accessKey = $accessKey;
        $this->secret    = $secret;
        parent::__construct($this->srvUrl, '80');
    }

    public function idCardNoCertify($real_name, $id_card_no)
    {
        ThirdUse::addCertifyUsedNum();
        $params = [
            'accesskey'  => $this->accessKey,
            'secret'     => $this->secret,
            'realname'   => $real_name,
            'idcard'     => $id_card_no,
        ];
        $result = $this->request('/open/api/qry/data/43', $params, Request::POST_METHOD);
        if (isset($result['ret']) && $result['ret'] == "0") {
            $res = $result['data']['res'];
            if ($res == 2) {
                ExceptionSms::returnError('姓名和身份证号不匹配');
            }
            return true;
        } else {
            ExceptionSms::returnError($result['msg'] ?? "");
            return false;
        }
    }
}
